package com.marchsoft.musicalstore.service;
import com.marchsoft.musicalstore.repository.StuCourseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.xml.crypto.Data;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 云
 * Date: 2019-11-22
 * Time: 19:36
 *
 */
@Service
public class SelStuCourse<list> {

    @Autowired
    StuCourseRepository stuCourseRepository;

    //通过id获取个人课程信息
    public List<com.marchsoft.musicalstore.entity.StuCourse> getPerCourse(int id){
        return  stuCourseRepository.findById(id);
    }

    //通过时间和id获取今日课程信息
    public List<com.marchsoft.musicalstore.entity.StuCourse> getPerTodayCourse(int id, Data PickClassData){
        return  stuCourseRepository.findByIdAndPickClassData(id,PickClassData);
    }

    public List<com.marchsoft.musicalstore.entity.SelfTodayClass> getOneClass(int id, Date date,int type){
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        return stuCourseRepository.queryAllByClassType(id,w,type);
    }


}
